package operation.cust;

import operation.chef.Ioperation;
import zy.Cust;
import zy.Warehouse;

import java.util.Scanner;

/*
 *@Student 张策
 */
public class cust4 implements Ioperation2 {
    @Override
    public void work(Warehouse warehouse, Cust cust) {
        if(cust.getVIP().equals("VIP用户")){
            System.out.println("已注册VIP");
            return;
        } else {
            System.out.println("确定要注册VIP吗?(Y/N)(注册VIP需要200元)");
            Scanner scanner=new Scanner(System.in);
            while (true) {
                String or = scanner.nextLine();
                while (!or.equals("Y")&&!or.equals("N")){
                    System.out.println("请重新输入");
                    or=scanner.nextLine();
                }
                if (or.equals("Y")) {
                    System.out.println("正在授权中...");
                    if(cust.getMoney()<200){
                        System.out.println("金额不足200元，请充值后再操作！");
                        return;
                    }
                    cust.setMoney(cust.getMoney()-200);
                    cust.setVIP("VIP用户");
                    System.out.println("授权成功!");
                    return;
                } else if (or.equals("N")) {
                    System.out.println("已取消");
                    return;
                } else {
                    System.out.println("输入错误请重新输入");
                }
            }
        }
    }
}
